package com.bilin.coin.utils;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import com.bilin.coin.R;


/**
 * Created by LG on 2017/6/14.
 */

public class DialogUtils {


    private static View viewLoading;

    private static Dialog mDialogLoading;

    /**
     * 等待的对话框
     */
    public static void showDialogLoading(Context context) {
      /*  if(mDialogLoading!=null){
           mDialogLoading.show();

        }else{*/
        if (context instanceof Activity && !((Activity) context).isDestroyed()) {
            mDialogLoading = new Dialog(context, R.style.Dialog);
            mDialogLoading.setContentView(setViewLoading(context));
            mDialogLoading.show();
        }
        /* }*/
    }

    /**
     * 关闭等待对话框
     */
    public static void dismissDialogLoading() {
        if (mDialogLoading != null && mDialogLoading.isShowing()) {
            mDialogLoading.dismiss();
        }
    }

    /**
     * 等待对话框的view
     *
     * @param context
     * @return
     */
    public static View setViewLoading(Context context) {
        viewLoading = LayoutInflater.from(context).inflate(R.layout.public_dialog_loading, null);
       /*ImageView ivLoading= (ImageView) viewLoading.findViewById(R.id.iv_loading);
       Glide.with(context).load(R.drawable.wait).asGif().into(ivLoading);*/
        return viewLoading;
    }


}
